<template>
<div class="app-container">
  <el-form ref="form" :model="form" :rules="rules" label-width="120px">
    <el-row>
      <el-col :span="24">
        <el-form-item label="网站地址" prop="website">
          <el-input v-model="form.website" placeholder="请输入网站地址" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="站点标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入站点标题" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="站点关键字" prop="keywords">
          <el-input v-model="form.keywords" placeholder="请输入站点关键字" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="站点描述" prop="describe">
          <el-input v-model="form.describe" placeholder="请输入站点描述" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="默认上传目录" prop="uploaddir">
          <el-input v-model="form.uploaddir" placeholder="请输入默认上传目录" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24" style="padding-top: 26px">
        <el-form-item label="站点浏览方式">
          <el-radio-group v-model="form.browseType">
            <el-radio
              v-for="dict in dict.type.cms_system_type"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="默认静态化目录" prop="staticdir">
          <el-input v-model="form.staticdir" placeholder="请输入默认静态化目录" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="备案号" prop="icp">
          <el-input v-model="form.icp" placeholder="请输入备案号" style="width: 500px"/>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="站点版权" prop="copyright">
          <el-input v-model="form.copyright" placeholder="请输入站点版权" style="width: 500px"/>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="updateCurrSystem">保存配置</el-button>
  </div>
</div>
</template>

<script>
import {getSystem,updateSystem} from "@/api/cms/demo";
export default {
  name: "webmg",
  dicts: ['cms_system_type'],
  data() {
    return {
      form: {

      },
      rules: {

      }
    }
  },
  created() {
    this.getCurrSystem();
  },
  methods: {
    getCurrSystem() {
      getSystem().then(response=>{
        this.form = response.data;
        this.form.browseType = ''+response.data.browseType;
      });
    },
    updateCurrSystem() {
      updateSystem(this.form).then(response=>{
        if(response.code == 200) {
          this.$message({
            message: '修改成功',
            type: 'success'
          });
        }else{
          this.$message({
            message: '修改失败',
            type: 'success'
          });
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
